package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.vo.SysWhitePaperOutlineVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysWhitePaperOutlineMapper;
import com.ruoyi.system.domain.SysWhitePaperOutline;
import com.ruoyi.system.service.ISysWhitePaperOutlineService;

/**
 * 白皮书大纲Service业务层处理
 *
 * @author ruoyi
 * @date 2025-10-20
 */
@Service
public class SysWhitePaperOutlineServiceImpl implements ISysWhitePaperOutlineService
{
    @Autowired
    private SysWhitePaperOutlineMapper sysWhitePaperOutlineMapper;

    /**
     * 查询白皮书大纲
     *
     * @param id 白皮书大纲主键
     * @return 白皮书大纲
     */
    @Override
    public SysWhitePaperOutline selectSysWhitePaperOutlineById(Long id)
    {
        return sysWhitePaperOutlineMapper.selectSysWhitePaperOutlineById(id);
    }

    /**
     * 查询白皮书大纲列表
     * @return 白皮书大纲
     */
    @Override
    public List<SysWhitePaperOutlineVo> selectSysWhitePaperOutlineList(Long projectId)
    {
        return sysWhitePaperOutlineMapper.selectSysWhitePaperOutlineList(projectId);
    }

    /**
     * 新增白皮书大纲
     *
     * @param sysWhitePaperOutline 白皮书大纲
     * @return 结果
     */
    @Override
    public int insertSysWhitePaperOutline(SysWhitePaperOutline sysWhitePaperOutline)
    {
        sysWhitePaperOutline.setCreateTime(DateUtils.getNowDate());
        return sysWhitePaperOutlineMapper.insertSysWhitePaperOutline(sysWhitePaperOutline);
    }

    /**
     * 修改白皮书大纲
     *
     * @param sysWhitePaperOutline 白皮书大纲
     * @return 结果
     */
    @Override
    public int updateSysWhitePaperOutline(SysWhitePaperOutline sysWhitePaperOutline)
    {
//        sysWhitePaperOutline.setUpdateBy(SecurityUtils.getUsername());
//        sysWhitePaperOutline.setUpdateTime(DateUtils.getNowDate());
        return sysWhitePaperOutlineMapper.updateSysWhitePaperOutline(sysWhitePaperOutline);
    }

    /**
     * 批量删除白皮书大纲
     *
     * @param ids 需要删除的白皮书大纲主键
     * @return 结果
     */
    @Override
    public int deleteSysWhitePaperOutlineByIds(Long[] ids)
    {
        return sysWhitePaperOutlineMapper.deleteSysWhitePaperOutlineByIds(ids);
    }

    /**
     * 删除白皮书大纲信息
     *
     * @param id 白皮书大纲主键
     * @return 结果
     */
    @Override
    public int deleteSysWhitePaperOutlineById(Long id)
    {
        return sysWhitePaperOutlineMapper.deleteSysWhitePaperOutlineById(id);
    }

    @Override
    public void batchInsertSysWhitePaperOutline(List<SysWhitePaperOutline> whitePaperOutlineList) {
        for (SysWhitePaperOutline whitePaperOutline:whitePaperOutlineList) {
            sysWhitePaperOutlineMapper.insertSysWhitePaperOutline(whitePaperOutline);
        }
//        sysWhitePaperOutlineMapper.batchInsertSysWhitePaperOutline(whitePaperOutlineList);
    }

    @Override
    public int deleteSysWhitePaperOutlineByProjectId(Long projectId) {
        return sysWhitePaperOutlineMapper.deleteSysWhitePaperOutlineByProjectId(projectId);
    }
}
